package cn.itamt.stars.base {
	import cn.itamt.stars.base.IStar;

	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.geom.Rectangle;	

	/**
	 * @author tamt
	 */
	public class Star implements IStar {
		protected var x : Number;
		protected var y : Number;
		protected var _view : DisplayObject;
		protected var _rect : Rectangle;

		public function build(rendererClass : Class, rect : Rectangle, container : DisplayObjectContainer) : void {
			_rect = rect;
			
			var instance : * = new rendererClass();
			if(instance is DisplayObject) {
				_view = instance;
				container.addChild(_view);
			} else {
				throw new ArgumentError('the rendererClass most be the subclass of DisplayObject.');
				return;
			}
		}

		public function update() : void {
		}

		public function render() : void {
			_view.x = x;
			_view.y = y;
		}
	}
}
